package view;

import java.awt.BorderLayout;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.GridLayout;

import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JTextArea;
import javax.swing.JTextField;

import controller.AddcontactmenuListener;
import controller.ListmenuListener;
import model.Adressbook;

/**
 * 
 * @author Nelly-Kim TRAN
 * 
 * The first view we see. It launches the application by creating an object addressbook.
 * 
 *
 */

public class IndexView extends JFrame{
	
	Adressbook adbook=new Adressbook();
	JPanel panel=new JPanel(new GridBagLayout());

	JLabel text=new JLabel("Welcome to your Adress Book!");
	
	//Menu
	JMenuBar menubar=new JMenuBar();
	JMenu menu1=new JMenu("Add Contact");
	JMenuItem item1=new JMenuItem("Add!");
	JMenu menu4=new JMenu("List of Contacts");
	JMenuItem item4=new JMenuItem("See the list!");
	
	public IndexView() {
		super();
		setTitle("My address book"); 
		setSize(600,600);
		
		//Menu initialization
		menubar.add(menu1);	
		menu1.add(item1);
		menubar.add(menu4);
		menu4.add(item4);
		setJMenuBar(menubar);
		panel.add(text);
		setContentPane(panel);
		
		//Listener for the menu
		AddcontactmenuListener listener1=new AddcontactmenuListener(this);
		item1.addActionListener(listener1);
		
		ListmenuListener listener2=new ListmenuListener(this);
		item4.addActionListener(listener2);

	}

}
